[deps]
util-macros
pixman
xorg-proto-headers
xorg-libraries
libxkbfile
freetype
libfontenc
libxau
libxdmcp
libxfont
mesalib
xcb-util-image
xcb-util
xcb-util-keysyms
xcb-util-wm

[main]
filesize=5806406
sha512=c0459ed95a6682b2094340b6b8fc7b59fcda5227ee2f13e87f68eb5c29b91cd3f05c5fc2126e33d6303beb3ad04d19466951ef4eb53f2e9918684cdaf3692c5a

[mirrors]
ftp://ftp.x.org/pub/individual/xserver/xorg-server-1.16.3.tar.bz2

[build]
printf "all:\n\ttrue\n\ninstall:\n\ttrue\n\n" > test/Makefile.in
sed -i 's/termio.h/termios.h/' hw/xfree86/os-support/xf86_OSlib.h

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine|sed 's/musl/gnu/') --with-sysroot=$butch_root_dir"
LDFLAGS="-lfontenc -lfreetype -lz -lxcb -lXdmcp -lXau $optldflags" \
  CFLAGS="-D__gid_t=gid_t -D__uid_t=uid_t -DNOFILES_MAX=256 -D_GNU_SOURCE -I$butch_prefix/include/pixman-1 $optcflags" \
  ./configure -C --prefix="$butch_prefix" \
  --enable-kdrive --enable-kdrive-evdev $xconfflags \
  --enable-dri \
  --enable-dri2 \
  --disable-glamor \
  --enable-glx-tls \
  --enable-aiglx \
  --enable-xfbdev \
  --enable-xorg \
  --enable-xv \
  --enable-xres \
  --enable-xace \
  --enable-xnest \
  --enable-xephyr \
  --disable-config-hal \
  --disable-dmx \
  --disable-tslib

make -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

# make /etc/X11 a symlink to /share/X11, so the config can be found easily
dest="${butch_prefix}${butch_install_dir}"
mkdir -p "$dest"/etc
ln -s ../share/X11 "$dest"/etc/

#copy our hacky X launcher script to /bin...
dest="${butch_prefix}${butch_install_dir}"/bin
mkdir -p "$dest"
cp "$K"/X "$dest"/

xmoddest="${butch_prefix}${butch_install_dir}"/share/X11/xorg.conf.d
mkdir -p "$xmoddest"
cp "$K"/20-modules.conf "$xmoddest"/

# FIXME starting X as non-root needs suid bit on the "server"
chmod +s "$dest"/Xfbdev
